package cn.edu.tju.mining.ldj;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import cn.edu.tju.mining.vo.report.Report;

public class InitQueryFormServlet extends HttpServlet {
	/**
	 * 
	 */
	private static Logger logger;
	
	static {
		logger = Logger.getLogger(DoQueryServlet.class.getName());
	}
	private static final long serialVersionUID = 1L;
	private String reportId;
	

	public String getReportId() {
		return reportId;
	}

	public void setReportId(String reportId) {
		this.reportId = reportId;
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		reportId = request.getParameter("reportId");
		Report rep = null;
		try {
			rep = ReportPageProcessing.getReport(reportId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			rep.queryDb();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		for (int i = 0; i < rep.getUserInputCompnents().getDepRelated().getListValues().size(); i++) {
//			System.out.println(rep.getUserInputCompnents().getDepRelated().getListValues().get(i).getCaption() + "----"+ rep.getUserInputCompnents().getDepRelated().getListValues().get(i).isSelected());
//		}
		logger.debug("queryReport StartDate type: "+rep.getUserInputCompnents().getStartDate().getType());
		request.getSession().setAttribute("queryReport", rep);
		request.getSession().setAttribute("reportId", reportId);
		response.sendRedirect("/dmining/reportPages/queryForm.jsp");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}
}
